/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DA;

import BO.GastoAdicional;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Daniel.Cerdas
 */
public class DAGastoAdicional {
   String conexionString = "jdbc:sqlserver://localhost:1433;" +
            "databaseName=Viaticos;user=sa; password=admin;";        
    
    Connection con = null;
    PreparedStatement pstmt = null;
    Statement stmt= null;
    ResultSet rs = null;
    public void insertarGastoAdicional(GastoAdicional GastoAdicionales) throws SQLException {
     try {   
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        con = DriverManager.getConnection(conexionString);
      
        String SQL = "insert into TablaOtrosGastos values (?,?,?,?);";
        pstmt = con.prepareStatement(SQL);
        pstmt.setInt(1,GastoAdicionales.getNumero());
        pstmt.setDouble(2,GastoAdicionales.getMonto());
        pstmt.setString(3, GastoAdicionales.getIDCentroCosto());
        pstmt.setString(4, GastoAdicionales.getDescripcionGasto());
        pstmt.executeUpdate();
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(DAFuncionarios.class.getName()).log(Level.SEVERE, null, ex);
    }
     finally {
        if (pstmt != null) { pstmt.close(); }
    }
    }
    
}
